<?php 
$rows = $this->db->query("select * from meterial_base_categories order by sort_order asc")->result_array();


?>
<select id="category_id" name="category_id">
 <?php  foreach($rows as $base){

?>

  <optgroup label="<?php echo $base["cat_base_name"]; ?>">
 <?php 
 $this->db->where("cat_base_id",$base["cat_base_id"]);
 $cats = $this->db->get("material_categories")->result_array();
 foreach($cats as $row){ ?>
    <option value="<?php echo  $row["category_id"]; ?>"><?php echo  $row["category_name"]; ?></option>
   

<?php } ?>
  </optgroup>
  <?php } ?>  
</select> 
